package com.csu.express.controller.app;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.csu.common.exception.WebException;
import com.csu.common.vo.ResultVo;
import com.csu.express.pojo.FeedbackPojo;
import com.csu.express.service.FeedbackService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import com.wordnik.swagger.annotations.ApiParam;

/**
 * @项目名称：express
 * @类名称：OrderCommentsController
 * @类描述：订单评价类（包括评价、查看评价信息）
 * @创建人：阳凯
 * @创建时间：2017年10月28日 下午7:06:52
 * @company:姚速运
 */
@Controller
@RequestMapping("/feedback")
@Api(value = "feedback", description = "用户反馈接口")
public class FeedbackController
{

    @Autowired
    private FeedbackService feedbackService;

    @ResponseBody
    @ApiOperation(value = "添加反馈记录", notes = "用户添加反馈记录")
    @RequestMapping(value = "/add", method = RequestMethod.POST, produces = { "application/json; charset=utf-8" })
    public ResultVo<Integer> addFeedback(HttpServletRequest request, @RequestBody FeedbackPojo feedbackPojo) throws WebException
    {
        ResultVo<Integer> resultVo = new ResultVo<>();
        int result = feedbackService.addFeedback(feedbackPojo);
        resultVo.setData(result);
        return resultVo;
    }

    @ResponseBody
    @ApiOperation(value = "分页获取反馈记录", notes = "用户分页获取反馈记录")
    @RequestMapping(value = "/list/{cellPhone}/{start}/{rows}", method = RequestMethod.GET, produces = { "application/json; charset=utf-8" })
    public ResultVo<List<FeedbackPojo>> getOrderCommentsByCellPhone(HttpServletRequest request,
            @ApiParam(value = "电话号码") @PathVariable(value = "cellPhone") String cellPhone,
            @ApiParam(value = "开始位置") @PathVariable(value = "start") Integer start,
            @ApiParam(value = "每页记录数") @PathVariable(value = "rows") Integer rows) throws WebException
    {
        ResultVo<List<FeedbackPojo>> resultVo = new ResultVo<>();
        List<FeedbackPojo> feedbackPojos = feedbackService.getFeedbackListByCellPhone(cellPhone, start, rows);
        resultVo.setData(feedbackPojos);
        return resultVo;
    }

}
